package sol.leetcode;

/**
 * Increasing Triplet Subsequence
 */
public class Issue334 {
    public boolean increasingTriplet(int[] nums) {
        Integer first = null, second = null;
        for (int i = 0; i < nums.length; ++i) {
            if (first == null || nums[i] <= first)
                first = nums[i];
            else if (second == null || nums[i] <= second)
                second = nums[i];
            else
                return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,1,1,1};
        Issue334 sol = new Issue334();
        System.out.println(sol.increasingTriplet(nums));
    }
}
